package usecase

import (
	"Data-API-MCP/backend/internal/domain/entity"
	"Data-API-MCP/backend/internal/domain/service"
	"context"
)

// ConnectionUseCase 连接用例
type ConnectionUseCase struct {
	connectionService *service.ConnectionService
}

// NewConnectionUseCase 创建连接用例
// @Summary 创建连接
// @Description 创建新的数据库连接
// @Tags connections
// @Accept json
// @Produce json
// @Param connection body entity.Connection true "连接信息"
func NewConnectionUseCase(connectionService *service.ConnectionService) *ConnectionUseCase {
	return &ConnectionUseCase{
		connectionService: connectionService,
	}
}

// CreateConnection 创建连接
func (u *ConnectionUseCase) CreateConnection(ctx context.Context, connection *entity.Connection) error {
	return u.connectionService.CreateConnection(ctx, connection)
}

// UpdateConnection 更新连接
func (u *ConnectionUseCase) UpdateConnection(ctx context.Context, connection *entity.Connection) error {
	return u.connectionService.UpdateConnection(ctx, connection)
}

// DeleteConnection 删除连接
func (u *ConnectionUseCase) DeleteConnection(ctx context.Context, id string) error {
	return u.connectionService.DeleteConnection(ctx, id)
}

// GetConnection 获取连接
func (u *ConnectionUseCase) GetConnection(ctx context.Context, id string) (*entity.Connection, error) {
	return u.connectionService.GetConnection(ctx, id)
}

// ListConnections 获取连接列表
func (u *ConnectionUseCase) ListConnections(ctx context.Context, offset, limit int) ([]*entity.Connection, error) {
	return u.connectionService.GetConnectionList(ctx, offset, limit)
}

// TestConnection 测试连接
func (u *ConnectionUseCase) TestConnection(ctx context.Context, connection *entity.Connection) error {
	return u.connectionService.TestConnection(ctx, connection)
}
